package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.admin.AnalysisByDay;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {

    @Select("select sum(num_registered) from tb_analysis_by_day")
    long selectUsers();

    @Select("select count(distinct user_id) from tb_log where log_time > #{lastDay,jdbcType=DATE}")
    long selectLastDay(String lastDay);

    @Select("select `id`,`record_date`,`num_registered`,`num_active`,`num_login`,`num_retention1d`,`created`,`updated` from tb_analysis_by_day where record_date = #{today,jdbcType=DATE}")
    AnalysisByDay findByRecordDate(String today);

    @Select("SELECT `id`,`record_date`,`num_registered`,`num_active`,`num_login`,`num_retention1d`,`created`,`updated` FROM tb_analysis_by_day WHERE record_date BETWEEN #{sd,jdbcType=DATE} AND #{ed,jdbcType=DATE}")
    List<AnalysisByDay> getRegistered(@Param("sd") String sd, @Param("ed") String ed);


}



